Closed
Bug 1073578
Opened 11 years ago
Closed 8 years ago
Make handling logging modules thread safe
Categories
(NSPR :: NSPR, defect)
NSPR
NSPR
Tracking
(Not tracked)
RESOLVED
INCOMPLETE
People
(Reporter: gsvelto, Unassigned)
References
(Blocks 1 open bug)
Details
Attachments
(4 files)
1.27 KB,
patch
|
Details | Diff | Splinter Review | |
2.01 KB,
patch
|
Details | Diff | Splinter Review | |
2.62 KB,
patch
|
Details | Diff | Splinter Review | |
3.06 KB,
patch
|
Details | Diff | Splinter Review |
Currently PR_NewLogModule() inserts new modules into a linked-list which isn't protected by a lock. This makes the call potentially racy opening up to the rare possibility that a new module is created but not inserted in the list as the head is overwritten by a module created simultaneously.
_PR_InitLog() which walks the module list can find himself in a similar situation (the module list being changed while it's already walking it) thus not walking over all the nodes.
Both use-cases should be protected by a lock to ensure they're thread-safe.
Comment 1•11 years ago
|
||
This patch moves the initialization of PR_Log to before NSPR init inserts log modules.
Attachment #8501290 -
Flags: review?(wtc)
Updated•11 years ago
|
Assignee: wtc → erahm
Status: NEW → ASSIGNED
Comment 2•11 years ago
|
||
This patch makes the _PR_LOCK macros reusable so that they can be used for another lock.
Attachment #8501291 -
Flags: review?(wtc)
Comment 3•11 years ago
|
||
This patch adds a lock for guarding access to the logModules global.
Attachment #8501293 -
Flags: review?(wtc)
Comment 4•11 years ago
|
||
And here we finally guard access to logModules when modifying its value or iterating over its entries.
Attachment #8501294 -
Flags: review?(wtc)
Comment 5•11 years ago
|
||
Is PR_NewLogModule() designed to be called in the main thread only?
Reporter | ||
Comment 6•11 years ago
|
||
(In reply to JW Wang [:jwwang] from comment #5)
> Is PR_NewLogModule() designed to be called in the main thread only?
It should be possible to call it from any thread; however until this bug is fixed doing so is racy.
Reporter | ||
Comment 7•11 years ago
|
||
(In reply to Eric Rahm [:erahm] from comment #4)
> And here we finally guard access to logModules when modifying its value or
> iterating over its entries.
Maybe it's overkill but wouldn't it be better to create a few thread-safe functions to manipulate logModules (e.g. insert a module, iterate over existing modules and perform an action, etc...) rather than modifying the existing uses? It would probably be more verbose but also cleaner and less prone to future mistakes.
Comment 8•11 years ago
|
||
(In reply to Gabriele Svelto [:gsvelto] from comment #7)
> (In reply to Eric Rahm [:erahm] from comment #4)
> > And here we finally guard access to logModules when modifying its value or
> > iterating over its entries.
>
> Maybe it's overkill but wouldn't it be better to create a few thread-safe
> functions to manipulate logModules (e.g. insert a module, iterate over
> existing modules and perform an action, etc...) rather than modifying the
> existing uses? It would probably be more verbose but also cleaner and less
> prone to future mistakes.
I think that would be an excellent follow up, particularly when we add more log module usage in bug 1074149. For now I'd like to keep this patch set as simple as possible.
Updated•9 years ago
|
Attachment #8501290 -
Flags: review?(wtc)
Updated•9 years ago
|
Attachment #8501291 -
Flags: review?(wtc)
Updated•9 years ago
|
Attachment #8501293 -
Flags: review?(wtc)
Updated•9 years ago
|
Attachment #8501294 -
Flags: review?(wtc)
Comment 9•9 years ago
|
||
Firefox no longer uses NSRP logging. I'll leave this bug open as it's still an issue in NSPR.
Assignee: erahm → nobody
Status: ASSIGNED → NEW
Comment 10•8 years ago
|
||
Lets just close this, odds are the patches still apply but it's gotten no traction.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → INCOMPLETE
You need to log in
before you can comment on or make changes to this bug.
Description
•